package chances.epg.entity.biz;

import java.util.ArrayList;
import java.util.List;

/**
 * 展示栏目推荐位.
 * @author libf
 *
 */
public class BizPosition {
	private Long id;
	private String bizCode;
	private String name;
	private String title;
	private String code;
	private String displayType;
	private int itemSize;
	
	private List<BizPositionItem> items;
	
	/**
	 * 添加推荐位元素.
	 * @param item
	 */
	public void addItem(BizPositionItem item) {
		//按照推荐位最大条目设置数据
		if(this.getItems().size() < this.itemSize){
			if(!this.getItems().contains(item)){
				this.getItems().add(item);
			}
		}
	}
	
	/**
	 * 添加推荐位元素.
	 * @param items
	 */
	public void addItems(List<BizPositionItem> items) {
		for (BizPositionItem item : items) {
			this.addItem(item);
		}
	}
	
	/**
	 * 获取第一条有效数据.
	 * @return
	 */
	public BizPositionItem getFirstValidItem() {
		return this.getItems().size() > 0 ? this.getItems().get(0) : null;
	}
	
	/**
	 * 获取推荐位元素.
	 * @return
	 */
	public List<BizPositionItem> getItems() {
		if(this.items == null) {
			this.items = new ArrayList<BizPositionItem>();
		}
		
		return this.items;
	}
	
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getBizCode() {
		return bizCode;
	}
	public void setBizCode(String bizCode) {
		this.bizCode = bizCode;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getDisplayType() {
		return displayType;
	}
	public void setDisplayType(String displayType) {
		this.displayType = displayType;
	}
	public int getItemSize() {
		return itemSize;
	}
	public void setItemSize(int itemSize) {
		this.itemSize = itemSize;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}
}
